{[{define "system/user/edit.html"}]}
<style>
    .layui-iconpicker-body.layui-iconpicker-body-page .hide {
        display: none;
    }
</style>
<link rel="stylesheet" href="/static/admin/css/public.css" media="all">
<link rel="stylesheet" href="/static/plugs/layui-v2.5.6/css/layui.css" media="all">
<link rel="stylesheet" href="/static/plugs/lay-module/autocomplete/autocomplete.css" media="all">
<link rel="stylesheet" href="/static/plugs/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
<div class="layuimini-container">
    <form id="app-form" class="layui-form layuimini-form">

        <input type="hidden" name="id" value="{[{.item.Id}]}">
        <div class="layui-form-item">
            <label class="layui-form-label required">名称</label>
            <div class="layui-input-inline">
                <input type="text" name="name" class="layui-input" lay-verify="required" lay-reqtext="请输入名称" placeholder="请输入名称" value="{[{.item.Name}]}" >
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label required">用户头像</label>
            <div class="layui-input-block layuimini-upload">
                <input name="head_img" class="layui-input layui-col-xs6" lay-verify="required" lay-reqtext="请上传用户头像" placeholder="请上传用户头像" value="{[{.item.Head_url}]}">
            </div>
            <ul id="bing-head_img" class="layui-input-block layuimini-upload-show">
                <li><a><img src="{[{.item.Head_url}]}"></a></li>
            </ul>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">手机号</label>
            <div class="layui-input-inline">
                <input type="text" name="phone" class="layui-input"  lay-reqtext="请输入手机号" placeholder="手机号" value="{[{.item.Phone}]}" >
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">会员</label>
            <div class="layui-input-block">
                <input type="radio" name="is_vip" value="0" title="非会员" {[{if eq .item.IsVip 0 }]}checked{[{end}]}>
                <input type="radio" name="is_vip" value="1" title="会员" {[{if eq .item.IsVip 1 }]}checked{[{end}]}>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">vip过期时间</label>
            <div class="layui-input-inline">
                <input type="text" name="expiration_time" id="date1" lay-verify="datetime" value="{[{.item.Expiration_time}]}"  autocomplete="off" class="layui-input">
            </div>
        </div>



        <div class="hr-line"></div>
        <div class="layui-form-item text-center">
            <button type="submit" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit lay-filter="add">确认</button>
            <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">重置</button>
        </div>

    </form>
</div>
<script src="/static/layuimini/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="/static/layuimini/js/lay-config.js" charset="utf-8"></script>
<script>

    layui.use(['form', 'jquery','sh','laydate'], function () {
        var $ = layui.jquery,
            form = layui.form,
            layer = layui.layer,
            sh = layui.sh,
            laydate = layui.laydate;


        var time = '{[{.item.Expiration_time}]}';

        if(time == ''){
            var date = new Date();
            var y = date.getFullYear()
            var m = (date.getMonth()+1) < 10 ? '0'+(date.getMonth()+1) : (date.getMonth()+1)
            var d = date.getDate() < 10 ? '0'+date.getDate() : date.getDate()
            var h = date.getHours()
            var i = date.getMinutes()
            var s = date.getSeconds()
            time = y+'-'+m+'-'+d+' '+h+':'+i+':'+s
        }

        laydate.render({
            elem: '#date1',
            type: 'datetime',
            value:time,
        });


        $(document).on('click',".delete1",function(){

            var id = $(this).attr("data");

            var obj = $(this);

            var _data = {
                id: id,
            };

            layer.confirm('是否确定要删除？', {icon: 3, title: '设备信息'}, function(index) {
                sh.request.post(
                    {
                        url: '{$ctr}/deldev',
                        data: _data,
                    }, function (res) {
                        if (res.code == 200) {
                            sh.msg.success('删除成功', function () {
                                window.location.reload();
                            });
                        } else {
                            sh.msg.error(data.msg, {icon: 2});
                        }

                    }
                );
                layer.close(index);
            });
            return false;
        });

        form.on('submit(add)', function (data) {

            data = data.field;
            sh.request.post(
                {
                    url: '/user/user/edit_ajax',
                    data: data,
                }, function (res) {
                    sh.msg.success('修改成功', function () {
                        window.parent.location.reload();//刷新父页面
                        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                        parent.layer.close(index);
                    });

                }
            );
            return false;
        });
    });

</script>
{[{end}]}